﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SpeakerRecognition
{
    /// <summary>
    /// Class for extracting the data from the input '.wav' file. in stereo or mono according to flag   
    /// </summary>
    public class WavFileExtractorCommand : ICommand
    {
        //************************  Private Fields  *******************************// 
        private String filePath;
        private double[] outputData;
        private bool usingStereo = false;
        private double[] outPutWithOutHeader;

     
        //************************  Public Properties  ****************************// 
        public bool UsingStereo
        {
            get { return usingStereo; }
            set { usingStereo = value; }
        }

        public double[] OutputData
        {
            get { return outputData; }
            set { outputData = value; }
        }

        public String FilePath
        {
            get { return filePath; }
            set { filePath = value; }
        }
        public double[] OutPutWithOutHeader
        {
            get { return outPutWithOutHeader; }
            set { outPutWithOutHeader = value; }
        }
        //************************  Public Methods  ****************************// 
        #region ICommand Members

        public void execute()
        {
            if (!usingStereo)
                outputData = clsWaveProcessor.GetWAVEDataInt16Mono(filePath);
            else
                outputData = clsWaveProcessor.GetWAVEDataInt16Stereo(filePath);
            OutPutWithOutHeader = new double[OutputData.Length - 7];
            for (int i = 7; i < OutputData.Length;i++)
            {
                OutPutWithOutHeader[i - 7] = OutputData[i];
            }
    
        }
        #endregion
    }
}
